<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>perldebug - Perl debugging - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/perldebug">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perldebug.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/perldebug">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/perldebug">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/perldebug">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/perldebug">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/perldebug">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/perldebug">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/perldebug">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/perldebug">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/perldebug">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/perldebug">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/perldebug">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/perldebug">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/perldebug">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/perldebug">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/perldebug">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/perldebug">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/perldebug">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/perldebug">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/perldebug">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/perldebug">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/perldebug">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/perldebug">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/perldebug">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/perldebug">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/perldebug">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/perldebug">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/perldebug">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/perldebug">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/perldebug">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/perldebug">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/perldebug">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/perldebug">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/perldebug">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/perldebug">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/perldebug">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/perldebug">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/perldebug">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/perldebug">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/perldebug">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/perldebug">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/perldebug">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/perldebug">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/perldebug">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/perldebug">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/perldebug">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/perldebug">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/perldebug">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/perldebug">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/perldebug">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/perldebug">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/perldebug">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/perldebug">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/perldebug">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/perldebug">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/perldebug">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/perldebug">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/perldebug">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/perldebug">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/perldebug">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/perldebug">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/perldebug">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/perldebug">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/perldebug">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/perldebug">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/perldebug">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/perldebug">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/perldebug">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/perldebug">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/perldebug">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/perldebug">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/perldebug">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/perldebug">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/perldebug">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/perldebug">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/perldebug">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/perldebug">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/perldebug">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/perldebug">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/perldebug">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/perldebug">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perldebug.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/perldebug">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/perldebug">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/perldebug">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/perldebug">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/perldebug">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/perldebug">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/perldebug">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/perldebug">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/perldebug">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/perldebug">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/perldebug">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/perldebug">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/perldebug">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/perldebug">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/perldebug">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/perldebug">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/perldebug">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/perldebug">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/perldebug">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/perldebug">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/perldebug">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/perldebug">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/perldebug">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/perldebug">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/perldebug">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/perldebug">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/perldebug">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/perldebug">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/perldebug">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/perldebug">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/perldebug">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/perldebug">5.35.1</a>
          <a class="dropdown-item active" href="perldebug.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perldebug.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="perldebug.html">perldebug</a>
          <div id="more">
            (<a href="perldebug.txt">source</a>,
            <a href="https://metacpan.org/pod/perldebug">CPAN</a>)
          </div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="perldebug.html#NAME">NAME  </a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#DESCRIPTION">DESCRIPTION</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#The-Perl-Debugger">The Perl Debugger</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perldebug.html#Calling-the-Debugger">Calling the Debugger</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#Debugger-Commands">Debugger Commands</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#Configurable-Options">Configurable Options</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#Debugger-Input/Output">Debugger Input/Output</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#Debugging-Compile-Time-Statements">Debugging Compile-Time Statements</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#Debugger-Customization">Debugger Customization</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#Readline-Support-/-History-in-the-Debugger">Readline Support / History in the Debugger</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#Editor-Support-for-Debugging">Editor Support for Debugging</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#The-Perl-Profiler">The Perl Profiler   </a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#Debugging-Regular-Expressions">Debugging Regular Expressions   </a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#Debugging-Memory-Usage">Debugging Memory Usage </a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#SEE-ALSO">SEE ALSO</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perldebug.html#BUGS">BUGS</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="perldebug.html#NAME">#</a>NAME  </h1>

<p>perldebug - Perl debugging</p>

<h1 id="DESCRIPTION"><a class="permalink" href="perldebug.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>First of all, have you tried using <a href="strict.html"><code>use strict;</code></a> and <a href="warnings.html"><code>use warnings;</code></a>?</p>

<p>If you&#39;re new to the Perl debugger, you may prefer to read <a href="perldebtut.html">perldebtut</a>, which is a tutorial introduction to the debugger.</p>

<p>If you&#39;re looking for the nitty gritty details of how the debugger is <i>implemented</i>, you may prefer to read <a href="perldebguts.html">perldebguts</a>.</p>

<p>For in-depth technical usage details, see <a href="perl5db.pl">perl5db.pl</a>, the documentation of the debugger itself.</p>

<h1 id="The-Perl-Debugger"><a class="permalink" href="perldebug.html#The-Perl-Debugger">#</a><a id="The"></a>The Perl Debugger</h1>

<p>If you invoke Perl with the <b>-d</b> switch, your script runs under the Perl source debugger. This works like an interactive Perl environment, prompting for debugger commands that let you examine source code, set breakpoints, get stack backtraces, change the values of variables, etc. This is so convenient that you often fire up the debugger all by itself just to test out Perl constructs interactively to see what they do. For example: </p>

<pre><code class="plaintext">$ perl -d -e 42</code></pre>

<p>In Perl, the debugger is not a separate program the way it usually is in the typical compiled environment. Instead, the <b>-d</b> flag tells the compiler to insert source information into the parse trees it&#39;s about to hand off to the interpreter. That means your code must first compile correctly for the debugger to work on it. Then when the interpreter starts up, it preloads a special Perl library file containing the debugger.</p>

<p>The program will halt <i>right before</i> the first run-time executable statement (but see below regarding compile-time statements) and ask you to enter a debugger command. Contrary to popular expectations, whenever the debugger halts and shows you a line of code, it always displays the line it&#39;s <i>about</i> to execute, rather than the one it has just executed.</p>

<p>Any command not recognized by the debugger is directly executed (<code>eval</code>&#39;d) as Perl code in the current package. (The debugger uses the DB package for keeping its own state information.)</p>

<p>Note that the said <code>eval</code> is bound by an implicit scope. As a result any newly introduced lexical variable or any modified capture buffer content is lost after the eval. The debugger is a nice environment to learn Perl, but if you interactively experiment using material which should be in the same scope, stuff it in one line.</p>

<p>For any text entered at the debugger prompt, leading and trailing whitespace is first stripped before further processing. If a debugger command coincides with some function in your own program, merely precede the function with something that doesn&#39;t look like a debugger command, such as a leading <code>;</code> or perhaps a <code>+</code>, or by wrapping it with parentheses or braces.</p>

<h2 id="Calling-the-Debugger"><a class="permalink" href="perldebug.html#Calling-the-Debugger">#</a><a id="Calling"></a>Calling the Debugger</h2>

<p>There are several ways to call the debugger:</p>

<dl>

<dt id="perl-d-program_name"><a class="permalink" href="perldebug.html#perl-d-program_name">#</a><a id="perl"></a><a id="perl--d-program_name"></a>perl -d program_name</dt>
<dd>

<p>On the given program identified by <code>program_name</code>.</p>

</dd>
<dt id="perl-d-e-0"><a class="permalink" href="perldebug.html#perl-d-e-0">#</a><a id="perl1"></a><a id="perl--d--e-0"></a>perl -d -e 0</dt>
<dd>

<p>Interactively supply an arbitrary <code>expression</code> using <code>-e</code>.</p>

</dd>
<dt id="perl-d:ptkdb-program_name"><a class="permalink" href="perldebug.html#perl-d:ptkdb-program_name">#</a><a id="perl2"></a><a id="perl--d:ptkdb-program_name"></a>perl -d:ptkdb program_name</dt>
<dd>

<p>Debug a given program via the <code>Devel::ptkdb</code> GUI.</p>

</dd>
<dt id="perl-dt-threaded_program_name"><a class="permalink" href="perldebug.html#perl-dt-threaded_program_name">#</a><a id="perl3"></a><a id="perl--dt-threaded_program_name"></a>perl -dt threaded_program_name</dt>
<dd>

<p>Debug a given program using threads (experimental).</p>

</dd>
</dl>

<h2 id="Debugger-Commands"><a class="permalink" href="perldebug.html#Debugger-Commands">#</a><a id="Debugger"></a>Debugger Commands</h2>

<p>The interactive debugger understands the following commands:</p>

<dl>

<dt id="h"><a class="permalink" href="perldebug.html#h">#</a>h </dt>
<dd>

<p>Prints out a summary help message</p>

</dd>
<dt id="h-[command]"><a class="permalink" href="perldebug.html#h-%5Bcommand%5D">#</a><a id="h1"></a><a id="h-command"></a>h [command]</dt>
<dd>

<p>Prints out a help message for the given debugger command.</p>

</dd>
<dt id="h-h"><a class="permalink" href="perldebug.html#h-h">#</a><a id="h2"></a>h h</dt>
<dd>

<p>The special argument of <code>h h</code> produces the entire help page, which is quite long.</p>

<p>If the output of the <code>h h</code> command (or any command, for that matter) scrolls past your screen, precede the command with a leading pipe symbol so that it&#39;s run through your pager, as in</p>

<pre><code class="plaintext">DB&gt; |h h</code></pre>

<p>You may change the pager which is used via <code>o pager=...</code> command.</p>

</dd>
<dt id="p-expr"><a class="permalink" href="perldebug.html#p-expr">#</a><a id="p"></a>p expr </dt>
<dd>

<p>Same as <code>print {$DB::OUT} expr</code> in the current package. In particular, because this is just Perl&#39;s own <code>print</code> function, this means that nested data structures and objects are not dumped, unlike with the <code>x</code> command.</p>

<p>The <code>DB::OUT</code> filehandle is opened to <i>/dev/tty</i>, regardless of where STDOUT may be redirected to.</p>

</dd>
<dt id="x-[maxdepth]-expr"><a class="permalink" href="perldebug.html#x-%5Bmaxdepth%5D-expr">#</a><a id="x"></a><a id="x-maxdepth-expr"></a>x [maxdepth] expr </dt>
<dd>

<p>Evaluates its expression in list context and dumps out the result in a pretty-printed fashion. Nested data structures are printed out recursively, unlike the real <code>print</code> function in Perl. When dumping hashes, you&#39;ll probably prefer &#39;x \%h&#39; rather than &#39;x %h&#39;. See <a href="Dumpvalue.html">Dumpvalue</a> if you&#39;d like to do this yourself.</p>

<p>The output format is governed by multiple options described under <a href="perldebug.html#Configurable-Options">&quot;Configurable Options&quot;</a>.</p>

<p>If the <code>maxdepth</code> is included, it must be a numeral <i>N</i>; the value is dumped only <i>N</i> levels deep, as if the <code>dumpDepth</code> option had been temporarily set to <i>N</i>.</p>

</dd>
<dt id="V-[pkg-[vars]]"><a class="permalink" href="perldebug.html#V-%5Bpkg-%5Bvars%5D%5D">#</a><a id="V"></a><a id="V-pkg-vars"></a>V [pkg [vars]] </dt>
<dd>

<p>Display all (or some) variables in package (defaulting to <code>main</code>) using a data pretty-printer (hashes show their keys and values so you see what&#39;s what, control characters are made printable, etc.). Make sure you don&#39;t put the type specifier (like <code>$</code>) there, just the symbol names, like this:</p>

<pre><code class="plaintext">V DB filename line</code></pre>

<p>Use <code>~pattern</code> and <code>!pattern</code> for positive and negative regexes.</p>

<p>This is similar to calling the <code>x</code> command on each applicable var.</p>

</dd>
<dt id="X-[vars]"><a class="permalink" href="perldebug.html#X-%5Bvars%5D">#</a><a id="X"></a><a id="X-vars"></a>X [vars] </dt>
<dd>

<p>Same as <code>V currentpackage [vars]</code>.</p>

</dd>
<dt id="y-[level-[vars]]"><a class="permalink" href="perldebug.html#y-%5Blevel-%5Bvars%5D%5D">#</a><a id="y"></a><a id="y-level-vars"></a>y [level [vars]] </dt>
<dd>

<p>Display all (or some) lexical variables (mnemonic: <code>mY</code> variables) in the current scope or <i>level</i> scopes higher. You can limit the variables that you see with <i>vars</i> which works exactly as it does for the <code>V</code> and <code>X</code> commands. Requires the <code>PadWalker</code> module version 0.08 or higher; will warn if this isn&#39;t installed. Output is pretty-printed in the same style as for <code>V</code> and the format is controlled by the same options.</p>

</dd>
<dt id="T"><a class="permalink" href="perldebug.html#T">#</a>T   </dt>
<dd>

<p>Produce a stack backtrace. See below for details on its output.</p>

</dd>
<dt id="s-[expr]"><a class="permalink" href="perldebug.html#s-%5Bexpr%5D">#</a><a id="s"></a><a id="s-expr"></a>s [expr]  </dt>
<dd>

<p>Single step. Executes until the beginning of another statement, descending into subroutine calls. If an expression is supplied that includes function calls, it too will be single-stepped.</p>

</dd>
<dt id="n-[expr]"><a class="permalink" href="perldebug.html#n-%5Bexpr%5D">#</a><a id="n"></a><a id="n-expr"></a>n [expr] </dt>
<dd>

<p>Next. Executes over subroutine calls, until the beginning of the next statement. If an expression is supplied that includes function calls, those functions will be executed with stops before each statement.</p>

</dd>
<dt id="r"><a class="permalink" href="perldebug.html#r">#</a>r </dt>
<dd>

<p>Continue until the return from the current subroutine. Dump the return value if the <code>PrintRet</code> option is set (default).</p>

</dd>
<dt id=""><a class="permalink" href="perldebug.html#">#</a><a id="&lt;CR&gt;"></a><a id="CR"></a>&lt;CR&gt;</dt>
<dd>

<p>Repeat last <code>n</code> or <code>s</code> command.</p>

</dd>
<dt id="c-[line|sub]"><a class="permalink" href="perldebug.html#c-%5Bline%7Csub%5D">#</a><a id="c"></a><a id="c-line-sub"></a>c [line|sub] </dt>
<dd>

<p>Continue, optionally inserting a one-time-only breakpoint at the specified line or subroutine.</p>

</dd>
<dt id="l"><a class="permalink" href="perldebug.html#l">#</a>l </dt>
<dd>

<p>List next window of lines.</p>

</dd>
<dt id="l-min+incr"><a class="permalink" href="perldebug.html#l-min+incr">#</a><a id="l1"></a><a id="l-min-incr"></a>l min+incr</dt>
<dd>

<p>List <code>incr+1</code> lines starting at <code>min</code>.</p>

</dd>
<dt id="l-min-max"><a class="permalink" href="perldebug.html#l-min-max">#</a><a id="l2"></a>l min-max</dt>
<dd>

<p>List lines <code>min</code> through <code>max</code>. <code>l -</code> is synonymous to <code>-</code>.</p>

</dd>
<dt id="l-line"><a class="permalink" href="perldebug.html#l-line">#</a><a id="l3"></a>l line</dt>
<dd>

<p>List a single line.</p>

</dd>
<dt id="l-subname"><a class="permalink" href="perldebug.html#l-subname">#</a><a id="l4"></a>l subname</dt>
<dd>

<p>List first window of lines from subroutine. <i>subname</i> may be a variable that contains a code reference.</p>

</dd>
<dt id="-"><a class="permalink" href="perldebug.html#-">#</a><a id="pod"></a>- </dt>
<dd>

<p>List previous window of lines.</p>

</dd>
<dt id="v-[line]"><a class="permalink" href="perldebug.html#v-%5Bline%5D">#</a><a id="v"></a><a id="v-line"></a>v [line] </dt>
<dd>

<p>View a few lines of code around the current line.</p>

</dd>
<dt id="."><a class="permalink" href="perldebug.html#.">#</a><a id="pod1"></a>. </dt>
<dd>

<p>Return the internal debugger pointer to the line last executed, and print out that line.</p>

</dd>
<dt id="f-filename"><a class="permalink" href="perldebug.html#f-filename">#</a><a id="f"></a>f filename </dt>
<dd>

<p>Switch to viewing a different file or <code>eval</code> statement. If <i>filename</i> is not a full pathname found in the values of %INC, it is considered a regex.</p>

<p><code>eval</code>ed strings (when accessible) are considered to be filenames: <code>f (eval 7)</code> and <code>f eval 7\b</code> access the body of the 7th <code>eval</code>ed string (in the order of execution). The bodies of the currently executed <code>eval</code> and of <code>eval</code>ed strings that define subroutines are saved and thus accessible.</p>

</dd>
<dt id="/pattern/"><a class="permalink" href="perldebug.html#/pattern/">#</a><a id="pattern"></a>/pattern/</dt>
<dd>

<p>Search forwards for pattern (a Perl regex); final / is optional. The search is case-insensitive by default.</p>

</dd>
<dt id="?pattern?"><a class="permalink" href="perldebug.html#?pattern?">#</a><a id="pattern1"></a>?pattern?</dt>
<dd>

<p>Search backwards for pattern; final ? is optional. The search is case-insensitive by default.</p>

</dd>
<dt id="L-[abw]"><a class="permalink" href="perldebug.html#L-%5Babw%5D">#</a><a id="L"></a><a id="L-abw"></a>L [abw] </dt>
<dd>

<p>List (default all) actions, breakpoints and watch expressions</p>

</dd>
<dt id="S-[[!]regex]"><a class="permalink" href="perldebug.html#S-%5B%5B!%5Dregex%5D">#</a><a id="S"></a><a id="S-regex"></a>S [[!]regex] </dt>
<dd>

<p>List subroutine names [not] matching the regex.</p>

</dd>
<dt id="t-[n]"><a class="permalink" href="perldebug.html#t-%5Bn%5D">#</a><a id="t"></a><a id="t-n"></a>t [n] </dt>
<dd>

<p>Toggle trace mode (see also the <code>AutoTrace</code> option). Optional argument is the maximum number of levels to trace below the current one; anything deeper than that will be silent.</p>

</dd>
<dt id="t-[n]-expr"><a class="permalink" href="perldebug.html#t-%5Bn%5D-expr">#</a><a id="t1"></a><a id="t-n-expr"></a>t [n] expr </dt>
<dd>

<p>Trace through execution of <code>expr</code>. Optional first argument is the maximum number of levels to trace below the current one; anything deeper than that will be silent. See <a href="perldebguts.html#Frame-Listing-Output-Examples">&quot;Frame Listing Output Examples&quot; in perldebguts</a> for examples.</p>

</dd>
<dt id="b"><a class="permalink" href="perldebug.html#b">#</a>b  </dt>
<dd>

<p>Sets breakpoint on current line</p>

</dd>
<dt id="b-[line]-[condition]"><a class="permalink" href="perldebug.html#b-%5Bline%5D-%5Bcondition%5D">#</a><a id="b1"></a><a id="b-line-condition"></a>b [line] [condition]  </dt>
<dd>

<p>Set a breakpoint before the given line. If a condition is specified, it&#39;s evaluated each time the statement is reached: a breakpoint is taken only if the condition is true. Breakpoints may only be set on lines that begin an executable statement. Conditions don&#39;t use <code>if</code>:</p>

<pre><code>b 237 $x &gt; 30
b 237 ++$count237 &lt; 11
b 33 /pattern/i</code></pre>

<p>If the line number is <code>.</code>, sets a breakpoint on the current line:</p>

<pre><code>b . $n &gt; 100</code></pre>

</dd>
<dt id="b-[file]:[line]-[condition]"><a class="permalink" href="perldebug.html#b-%5Bfile%5D:%5Bline%5D-%5Bcondition%5D">#</a><a id="b2"></a><a id="b-file-:-line-condition"></a>b [file]:[line] [condition]  </dt>
<dd>

<p>Set a breakpoint before the given line in a (possibly different) file. If a condition is specified, it&#39;s evaluated each time the statement is reached: a breakpoint is taken only if the condition is true. Breakpoints may only be set on lines that begin an executable statement. Conditions don&#39;t use <code>if</code>:</p>

<pre><code>b lib/MyModule.pm:237 $x &gt; 30
b /usr/lib/perl5/site_perl/CGI.pm:100 ++$count100 &lt; 11</code></pre>

</dd>
<dt id="b-subname-[condition]"><a class="permalink" href="perldebug.html#b-subname-%5Bcondition%5D">#</a><a id="b3"></a><a id="b-subname-condition"></a>b subname [condition]  </dt>
<dd>

<p>Set a breakpoint before the first line of the named subroutine. <i>subname</i> may be a variable containing a code reference (in this case <i>condition</i> is not supported).</p>

</dd>
<dt id="b-postpone-subname-[condition]"><a class="permalink" href="perldebug.html#b-postpone-subname-%5Bcondition%5D">#</a><a id="b4"></a><a id="b-postpone-subname-condition"></a>b postpone subname [condition]  </dt>
<dd>

<p>Set a breakpoint at first line of subroutine after it is compiled.</p>

</dd>
<dt id="b-load-filename"><a class="permalink" href="perldebug.html#b-load-filename">#</a><a id="b5"></a>b load filename  </dt>
<dd>

<p>Set a breakpoint before the first executed line of the <i>filename</i>, which should be a full pathname found amongst the %INC values.</p>

</dd>
<dt id="b-compile-subname"><a class="permalink" href="perldebug.html#b-compile-subname">#</a><a id="b6"></a>b compile subname  </dt>
<dd>

<p>Sets a breakpoint before the first statement executed after the specified subroutine is compiled.</p>

</dd>
<dt id="B-line"><a class="permalink" href="perldebug.html#B-line">#</a><a id="B"></a>B line  </dt>
<dd>

<p>Delete a breakpoint from the specified <i>line</i>.</p>

</dd>
<dt id="B-*"><a class="permalink" href="perldebug.html#B-*">#</a><a id="B1"></a>B *  </dt>
<dd>

<p>Delete all installed breakpoints.</p>

</dd>
<dt id="disable-[file]:[line]"><a class="permalink" href="perldebug.html#disable-%5Bfile%5D:%5Bline%5D">#</a><a id="disable"></a><a id="disable-file-:-line"></a>disable [file]:[line]   </dt>
<dd>

<p>Disable the breakpoint so it won&#39;t stop the execution of the program. Breakpoints are enabled by default and can be re-enabled using the <code>enable</code> command.</p>

</dd>
<dt id="disable-[line]"><a class="permalink" href="perldebug.html#disable-%5Bline%5D">#</a><a id="disable1"></a><a id="disable-line"></a>disable [line]   </dt>
<dd>

<p>Disable the breakpoint so it won&#39;t stop the execution of the program. Breakpoints are enabled by default and can be re-enabled using the <code>enable</code> command.</p>

<p>This is done for a breakpoint in the current file.</p>

</dd>
<dt id="enable-[file]:[line]"><a class="permalink" href="perldebug.html#enable-%5Bfile%5D:%5Bline%5D">#</a><a id="enable"></a><a id="enable-file-:-line"></a>enable [file]:[line]   </dt>
<dd>

<p>Enable the breakpoint so it will stop the execution of the program.</p>

</dd>
<dt id="enable-[line]"><a class="permalink" href="perldebug.html#enable-%5Bline%5D">#</a><a id="enable1"></a><a id="enable-line"></a>enable [line]   </dt>
<dd>

<p>Enable the breakpoint so it will stop the execution of the program.</p>

<p>This is done for a breakpoint in the current file.</p>

</dd>
<dt id="a-[line]-command"><a class="permalink" href="perldebug.html#a-%5Bline%5D-command">#</a><a id="a"></a><a id="a-line-command"></a>a [line] command </dt>
<dd>

<p>Set an action to be done before the line is executed. If <i>line</i> is omitted, set an action on the line about to be executed. The sequence of steps taken by the debugger is</p>

<pre><code class="plaintext">1. check for a breakpoint at this line
2. print the line if necessary (tracing)
3. do any actions associated with that line
4. prompt user if at a breakpoint or in single-step
5. evaluate line</code></pre>

<p>For example, this will print out $foo every time line 53 is passed:</p>

<pre><code>a 53 print &quot;DB FOUND $foo\n&quot;</code></pre>

</dd>
<dt id="A-line"><a class="permalink" href="perldebug.html#A-line">#</a><a id="A"></a>A line </dt>
<dd>

<p>Delete an action from the specified line.</p>

</dd>
<dt id="A-*"><a class="permalink" href="perldebug.html#A-*">#</a><a id="A1"></a>A * </dt>
<dd>

<p>Delete all installed actions.</p>

</dd>
<dt id="w-expr"><a class="permalink" href="perldebug.html#w-expr">#</a><a id="w"></a>w expr </dt>
<dd>

<p>Add a global watch-expression. Whenever a watched global changes the debugger will stop and display the old and new values.</p>

</dd>
<dt id="W-expr"><a class="permalink" href="perldebug.html#W-expr">#</a><a id="W"></a>W expr </dt>
<dd>

<p>Delete watch-expression</p>

</dd>
<dt id="W-*"><a class="permalink" href="perldebug.html#W-*">#</a><a id="W1"></a>W * </dt>
<dd>

<p>Delete all watch-expressions.</p>

</dd>
<dt id="o"><a class="permalink" href="perldebug.html#o">#</a>o </dt>
<dd>

<p>Display all options.</p>

</dd>
<dt id="o-booloption-..."><a class="permalink" href="perldebug.html#o-booloption-...">#</a><a id="o1"></a><a id="o-booloption"></a>o booloption ... </dt>
<dd>

<p>Set each listed Boolean option to the value <code>1</code>.</p>

</dd>
<dt id="o-anyoption?-..."><a class="permalink" href="perldebug.html#o-anyoption?-...">#</a><a id="o2"></a><a id="o-anyoption"></a>o anyoption? ... </dt>
<dd>

<p>Print out the value of one or more options.</p>

</dd>
<dt id="o-option=value-..."><a class="permalink" href="perldebug.html#o-option=value-...">#</a><a id="o3"></a><a id="o-option-value"></a>o option=value ... </dt>
<dd>

<p>Set the value of one or more options. If the value has internal whitespace, it should be quoted. For example, you could set <code>o pager=&quot;less -MQeicsNfr&quot;</code> to call <b>less</b> with those specific options. You may use either single or double quotes, but if you do, you must escape any embedded instances of same sort of quote you began with, as well as any escaping any escapes that immediately precede that quote but which are not meant to escape the quote itself. In other words, you follow single-quoting rules irrespective of the quote; eg: <code>o option=&#39;this isn\&#39;t bad&#39;</code> or <code>o option=&quot;She said, \&quot;Isn&#39;t it?\&quot;&quot;</code>.</p>

<p>For historical reasons, the <code>=value</code> is optional, but defaults to 1 only where it is safe to do so--that is, mostly for Boolean options. It is always better to assign a specific value using <code>=</code>. The <code>option</code> can be abbreviated, but for clarity probably should not be. Several options can be set together. See <a href="perldebug.html#Configurable-Options">&quot;Configurable Options&quot;</a> for a list of these.</p>

</dd>
<dt id="&lt;-?"><a class="permalink" href="perldebug.html#%3C-?">#</a><a id="pod2"></a>&lt; ? </dt>
<dd>

<p>List out all pre-prompt Perl command actions.</p>

</dd>
<dt id="&lt;-[-command-]"><a class="permalink" href="perldebug.html#%3C-%5B-command-%5D">#</a><a id="command1"></a>&lt; [ command ] </dt>
<dd>

<p>Set an action (Perl command) to happen before every debugger prompt. A multi-line command may be entered by backslashing the newlines.</p>

</dd>
<dt id="&lt;-*"><a class="permalink" href="perldebug.html#%3C-*">#</a><a id="pod3"></a>&lt; * </dt>
<dd>

<p>Delete all pre-prompt Perl command actions.</p>

</dd>
<dt id="&lt;&lt;-command"><a class="permalink" href="perldebug.html#%3C%3C-command">#</a><a id="command2"></a>&lt;&lt; command </dt>
<dd>

<p>Add an action (Perl command) to happen before every debugger prompt. A multi-line command may be entered by backwhacking the newlines.</p>

</dd>
<dt id="&gt;-?"><a class="permalink" href="perldebug.html#%3E-?">#</a><a id="pod4"></a>&gt; ? </dt>
<dd>

<p>List out post-prompt Perl command actions.</p>

</dd>
<dt id="&gt;-command"><a class="permalink" href="perldebug.html#%3E-command">#</a><a id="command3"></a>&gt; command </dt>
<dd>

<p>Set an action (Perl command) to happen after the prompt when you&#39;ve just given a command to return to executing the script. A multi-line command may be entered by backslashing the newlines (we bet you couldn&#39;t have guessed this by now).</p>

</dd>
<dt id="&gt;-*"><a class="permalink" href="perldebug.html#%3E-*">#</a><a id="pod5"></a>&gt; * </dt>
<dd>

<p>Delete all post-prompt Perl command actions.</p>

</dd>
<dt id="&gt;&gt;-command"><a class="permalink" href="perldebug.html#%3E%3E-command">#</a><a id="command4"></a>&gt;&gt; command </dt>
<dd>

<p>Adds an action (Perl command) to happen after the prompt when you&#39;ve just given a command to return to executing the script. A multi-line command may be entered by backslashing the newlines.</p>

</dd>
<dt id="{-?"><a class="permalink" href="perldebug.html#%7B-?">#</a><a id="pod6"></a>{ ? </dt>
<dd>

<p>List out pre-prompt debugger commands.</p>

</dd>
<dt id="{-[-command-]"><a class="permalink" href="perldebug.html#%7B-%5B-command-%5D">#</a><a id="command5"></a>{ [ command ]</dt>
<dd>

<p>Set an action (debugger command) to happen before every debugger prompt. A multi-line command may be entered in the customary fashion.</p>

<p>Because this command is in some senses new, a warning is issued if you appear to have accidentally entered a block instead. If that&#39;s what you mean to do, write it as with <code>;{ ... }</code> or even <code>do { ... }</code>.</p>

</dd>
<dt id="{-*"><a class="permalink" href="perldebug.html#%7B-*">#</a><a id="pod7"></a>{ * </dt>
<dd>

<p>Delete all pre-prompt debugger commands.</p>

</dd>
<dt id="{{-command"><a class="permalink" href="perldebug.html#%7B%7B-command">#</a><a id="command6"></a>{{ command </dt>
<dd>

<p>Add an action (debugger command) to happen before every debugger prompt. A multi-line command may be entered, if you can guess how: see above.</p>

</dd>
<dt id="!-number"><a class="permalink" href="perldebug.html#!-number">#</a><a id="number"></a>! number </dt>
<dd>

<p>Redo a previous command (defaults to the previous command).</p>

</dd>
<dt id="!-number1"><a class="permalink" href="perldebug.html#!-number1">#</a><a id="number1"></a>! -number </dt>
<dd>

<p>Redo number&#39;th previous command.</p>

</dd>
<dt id="!-pattern"><a class="permalink" href="perldebug.html#!-pattern">#</a><a id="pattern2"></a>! pattern </dt>
<dd>

<p>Redo last command that started with pattern. See <code>o recallCommand</code>, too.</p>

</dd>
<dt id="!!-cmd"><a class="permalink" href="perldebug.html#!!-cmd">#</a><a id="cmd"></a>!! cmd </dt>
<dd>

<p>Run cmd in a subprocess (reads from DB::IN, writes to DB::OUT) See <code>o shellBang</code>, also. Note that the user&#39;s current shell (well, their <code>$ENV{SHELL}</code> variable) will be used, which can interfere with proper interpretation of exit status or signal and coredump information.</p>

</dd>
<dt id="source-file"><a class="permalink" href="perldebug.html#source-file">#</a><a id="source"></a>source file </dt>
<dd>

<p>Read and execute debugger commands from <i>file</i>. <i>file</i> may itself contain <code>source</code> commands.</p>

</dd>
<dt id="H-number"><a class="permalink" href="perldebug.html#H-number">#</a><a id="H"></a><a id="H--number"></a>H -number </dt>
<dd>

<p>Display last n commands. Only commands longer than one character are listed. If <i>number</i> is omitted, list them all.</p>

</dd>
<dt id="q-or-^D"><a class="permalink" href="perldebug.html#q-or-%5ED">#</a><a id="q"></a><a id="q-or-D"></a>q or ^D  </dt>
<dd>

<p>Quit. (&quot;quit&quot; doesn&#39;t work for this, unless you&#39;ve made an alias) This is the only supported way to exit the debugger, though typing <code>exit</code> twice might work.</p>

<p>Set the <code>inhibit_exit</code> option to 0 if you want to be able to step off the end the script. You may also need to set $finished to 0 if you want to step through global destruction.</p>

</dd>
<dt id="R"><a class="permalink" href="perldebug.html#R">#</a>R </dt>
<dd>

<p>Restart the debugger by <code>exec()</code>ing a new session. We try to maintain your history across this, but internal settings and command-line options may be lost.</p>

<p>The following setting are currently preserved: history, breakpoints, actions, debugger options, and the Perl command-line options <b>-w</b>, <b>-I</b>, and <b>-e</b>.</p>

</dd>
<dt id="|dbcmd"><a class="permalink" href="perldebug.html#%7Cdbcmd">#</a><a id="dbcmd"></a>|dbcmd </dt>
<dd>

<p>Run the debugger command, piping DB::OUT into your current pager.</p>

</dd>
<dt id="||dbcmd"><a class="permalink" href="perldebug.html#%7C%7Cdbcmd">#</a><a id="dbcmd1"></a>||dbcmd </dt>
<dd>

<p>Same as <code>|dbcmd</code> but DB::OUT is temporarily <code>select</code>ed as well.</p>

</dd>
<dt id="=-[alias-value]"><a class="permalink" href="perldebug.html#=-%5Balias-value%5D">#</a><a id="alias-value"></a>= [alias value] </dt>
<dd>

<p>Define a command alias, like</p>

<pre><code class="plaintext">= quit q</code></pre>

<p>or list current aliases.</p>

</dd>
<dt id="command"><a class="permalink" href="perldebug.html#command">#</a>command</dt>
<dd>

<p>Execute command as a Perl statement. A trailing semicolon will be supplied. If the Perl statement would otherwise be confused for a Perl debugger, use a leading semicolon, too.</p>

</dd>
<dt id="m-expr"><a class="permalink" href="perldebug.html#m-expr">#</a><a id="m"></a>m expr </dt>
<dd>

<p>List which methods may be called on the result of the evaluated expression. The expression may evaluated to a reference to a blessed object, or to a package name.</p>

</dd>
<dt id="M"><a class="permalink" href="perldebug.html#M">#</a>M </dt>
<dd>

<p>Display all loaded modules and their versions.</p>

</dd>
<dt id="man-[manpage]"><a class="permalink" href="perldebug.html#man-%5Bmanpage%5D">#</a><a id="man"></a><a id="man-manpage"></a>man [manpage] </dt>
<dd>

<p>Despite its name, this calls your system&#39;s default documentation viewer on the given page, or on the viewer itself if <i>manpage</i> is omitted. If that viewer is <b>man</b>, the current <code>Config</code> information is used to invoke <b>man</b> using the proper MANPATH or <span style="white-space: nowrap;"><b>-M</b> <i>manpath</i></span> option. Failed lookups of the form <code>XXX</code> that match known manpages of the form <i>perlXXX</i> will be retried. This lets you type <code>man debug</code> or <code>man op</code> from the debugger.</p>

<p>On systems traditionally bereft of a usable <b>man</b> command, the debugger invokes <b>perldoc</b>. Occasionally this determination is incorrect due to recalcitrant vendors or rather more felicitously, to enterprising users. If you fall into either category, just manually set the $DB::doccmd variable to whatever viewer to view the Perl documentation on your system. This may be set in an rc file, or through direct assignment. We&#39;re still waiting for a working example of something along the lines of:</p>

<pre><code>$DB::doccmd = &#39;netscape -remote http://something.here/&#39;;</code></pre>

</dd>
</dl>

<h2 id="Configurable-Options"><a class="permalink" href="perldebug.html#Configurable-Options">#</a><a id="Configurable"></a>Configurable Options</h2>

<p>The debugger has numerous options settable using the <code>o</code> command, either interactively or from the environment or an rc file. The file is named <i>./.perldb</i> or <i>~/.perldb</i> under Unix with <i>/dev/tty</i>, <i>perldb.ini</i> otherwise.</p>

<dl>

<dt id="recallCommand,-ShellBang"><a class="permalink" href="perldebug.html#recallCommand,-ShellBang">#</a><a id="recallCommand"></a><a id="recallCommand-ShellBang"></a><code>recallCommand</code>, <code>ShellBang</code>  </dt>
<dd>

<p>The characters used to recall a command or spawn a shell. By default, both are set to <code>!</code>, which is unfortunate.</p>

</dd>
<dt id="pager"><a class="permalink" href="perldebug.html#pager">#</a><code>pager</code> </dt>
<dd>

<p>Program to use for output of pager-piped commands (those beginning with a <code>|</code> character.) By default, <code>$ENV{PAGER}</code> will be used. Because the debugger uses your current terminal characteristics for bold and underlining, if the chosen pager does not pass escape sequences through unchanged, the output of some debugger commands will not be readable when sent through the pager.</p>

</dd>
<dt id="tkRunning"><a class="permalink" href="perldebug.html#tkRunning">#</a><code>tkRunning</code> </dt>
<dd>

<p>Run Tk while prompting (with ReadLine).</p>

</dd>
<dt id="signalLevel,-warnLevel,-dieLevel"><a class="permalink" href="perldebug.html#signalLevel,-warnLevel,-dieLevel">#</a><a id="signalLevel"></a><a id="signalLevel-warnLevel-dieLevel"></a><code>signalLevel</code>, <code>warnLevel</code>, <code>dieLevel</code>   </dt>
<dd>

<p>Level of verbosity. By default, the debugger leaves your exceptions and warnings alone, because altering them can break correctly running programs. It will attempt to print a message when uncaught INT, BUS, or SEGV signals arrive. (But see the mention of signals in <a href="perldebug.html#BUGS">&quot;BUGS&quot;</a> below.)</p>

<p>To disable this default safe mode, set these values to something higher than 0. At a level of 1, you get backtraces upon receiving any kind of warning (this is often annoying) or exception (this is often valuable). Unfortunately, the debugger cannot discern fatal exceptions from non-fatal ones. If <code>dieLevel</code> is even 1, then your non-fatal exceptions are also traced and unceremoniously altered if they came from <code>eval&#39;ed</code> strings or from any kind of <code>eval</code> within modules you&#39;re attempting to load. If <code>dieLevel</code> is 2, the debugger doesn&#39;t care where they came from: It usurps your exception handler and prints out a trace, then modifies all exceptions with its own embellishments. This may perhaps be useful for some tracing purposes, but tends to hopelessly destroy any program that takes its exception handling seriously.</p>

</dd>
<dt id="AutoTrace"><a class="permalink" href="perldebug.html#AutoTrace">#</a><code>AutoTrace</code> </dt>
<dd>

<p>Trace mode (similar to <code>t</code> command, but can be put into <code>PERLDB_OPTS</code>).</p>

</dd>
<dt id="LineInfo"><a class="permalink" href="perldebug.html#LineInfo">#</a><code>LineInfo</code> </dt>
<dd>

<p>File or pipe to print line number info to. If it is a pipe (say, <code>|visual_perl_db</code>), then a short message is used. This is the mechanism used to interact with a slave editor or visual debugger, such as the special <code>vi</code> or <code>emacs</code> hooks, or the <code>ddd</code> graphical debugger.</p>

</dd>
<dt id="inhibit_exit"><a class="permalink" href="perldebug.html#inhibit_exit">#</a><code>inhibit_exit</code> </dt>
<dd>

<p>If 0, allows <i>stepping off</i> the end of the script.</p>

</dd>
<dt id="PrintRet"><a class="permalink" href="perldebug.html#PrintRet">#</a><code>PrintRet</code> </dt>
<dd>

<p>Print return value after <code>r</code> command if set (default).</p>

</dd>
<dt id="ornaments"><a class="permalink" href="perldebug.html#ornaments">#</a><code>ornaments</code> </dt>
<dd>

<p>Affects screen appearance of the command line (see <a href="./Term::ReadLine.html">Term::ReadLine</a>). There is currently no way to disable these, which can render some output illegible on some displays, or with some pagers. This is considered a bug.</p>

</dd>
<dt id="frame"><a class="permalink" href="perldebug.html#frame">#</a><code>frame</code> </dt>
<dd>

<p>Affects the printing of messages upon entry and exit from subroutines. If <code>frame &amp; 2</code> is false, messages are printed on entry only. (Printing on exit might be useful if interspersed with other messages.)</p>

<p>If <code>frame &amp; 4</code>, arguments to functions are printed, plus context and caller info. If <code>frame &amp; 8</code>, overloaded <code>stringify</code> and <code>tie</code>d <code>FETCH</code> is enabled on the printed arguments. If <code>frame &amp; 16</code>, the return value from the subroutine is printed.</p>

<p>The length at which the argument list is truncated is governed by the next option:</p>

</dd>
<dt id="maxTraceLen"><a class="permalink" href="perldebug.html#maxTraceLen">#</a><code>maxTraceLen</code> </dt>
<dd>

<p>Length to truncate the argument list when the <code>frame</code> option&#39;s bit 4 is set.</p>

</dd>
<dt id="windowSize"><a class="permalink" href="perldebug.html#windowSize">#</a><code>windowSize</code> </dt>
<dd>

<p>Change the size of code list window (default is 10 lines).</p>

</dd>
</dl>

<p>The following options affect what happens with <code>V</code>, <code>X</code>, and <code>x</code> commands:</p>

<dl>

<dt id="arrayDepth,-hashDepth"><a class="permalink" href="perldebug.html#arrayDepth,-hashDepth">#</a><a id="arrayDepth"></a><a id="arrayDepth-hashDepth"></a><code>arrayDepth</code>, <code>hashDepth</code>  </dt>
<dd>

<p>Print only first N elements (&#39;&#39; for all).</p>

</dd>
<dt id="dumpDepth"><a class="permalink" href="perldebug.html#dumpDepth">#</a><code>dumpDepth</code> </dt>
<dd>

<p>Limit recursion depth to N levels when dumping structures. Negative values are interpreted as infinity. Default: infinity.</p>

</dd>
<dt id="compactDump,-veryCompact"><a class="permalink" href="perldebug.html#compactDump,-veryCompact">#</a><a id="compactDump"></a><a id="compactDump-veryCompact"></a><code>compactDump</code>, <code>veryCompact</code>  </dt>
<dd>

<p>Change the style of array and hash output. If <code>compactDump</code>, short array may be printed on one line.</p>

</dd>
<dt id="globPrint"><a class="permalink" href="perldebug.html#globPrint">#</a><code>globPrint</code> </dt>
<dd>

<p>Whether to print contents of globs.</p>

</dd>
<dt id="DumpDBFiles"><a class="permalink" href="perldebug.html#DumpDBFiles">#</a><code>DumpDBFiles</code> </dt>
<dd>

<p>Dump arrays holding debugged files.</p>

</dd>
<dt id="DumpPackages"><a class="permalink" href="perldebug.html#DumpPackages">#</a><code>DumpPackages</code> </dt>
<dd>

<p>Dump symbol tables of packages.</p>

</dd>
<dt id="DumpReused"><a class="permalink" href="perldebug.html#DumpReused">#</a><code>DumpReused</code> </dt>
<dd>

<p>Dump contents of &quot;reused&quot; addresses.</p>

</dd>
<dt id="quote,-HighBit,-undefPrint"><a class="permalink" href="perldebug.html#quote,-HighBit,-undefPrint">#</a><a id="quote"></a><a id="quote-HighBit-undefPrint"></a><code>quote</code>, <code>HighBit</code>, <code>undefPrint</code>   </dt>
<dd>

<p>Change the style of string dump. The default value for <code>quote</code> is <code>auto</code>; one can enable double-quotish or single-quotish format by setting it to <code>&quot;</code> or <code>&#39;</code>, respectively. By default, characters with their high bit set are printed verbatim.</p>

</dd>
<dt id="UsageOnly"><a class="permalink" href="perldebug.html#UsageOnly">#</a><code>UsageOnly</code> </dt>
<dd>

<p>Rudimentary per-package memory usage dump. Calculates total size of strings found in variables in the package. This does not include lexicals in a module&#39;s file scope, or lost in closures.</p>

</dd>
<dt id="HistFile"><a class="permalink" href="perldebug.html#HistFile">#</a><code>HistFile</code> </dt>
<dd>

<p>The path of the file from which the history (assuming a usable Term::ReadLine backend) will be read on the debugger&#39;s startup, and to which it will be saved on shutdown (for persistence across sessions). Similar in concept to Bash&#39;s <code>.bash_history</code> file.</p>

</dd>
<dt id="HistSize"><a class="permalink" href="perldebug.html#HistSize">#</a><code>HistSize</code> </dt>
<dd>

<p>The count of the saved lines in the history (assuming <code>HistFile</code> above).</p>

</dd>
</dl>

<p>After the rc file is read, the debugger reads the <code>$ENV{PERLDB_OPTS}</code> environment variable and parses this as the remainder of a &quot;O ...&quot; line as one might enter at the debugger prompt. You may place the initialization options <code>TTY</code>, <code>noTTY</code>, <code>ReadLine</code>, and <code>NonStop</code> there.</p>

<p>If your rc file contains:</p>

<pre><code>parse_options(&quot;NonStop=1 LineInfo=db.out AutoTrace&quot;);</code></pre>

<p>then your script will run without human intervention, putting trace information into the file <i>db.out</i>. (If you interrupt it, you&#39;d better reset <code>LineInfo</code> to <i>/dev/tty</i> if you expect to see anything.)</p>

<dl>

<dt id="TTY"><a class="permalink" href="perldebug.html#TTY">#</a><code>TTY</code> </dt>
<dd>

<p>The TTY to use for debugging I/O.</p>

</dd>
<dt id="noTTY"><a class="permalink" href="perldebug.html#noTTY">#</a><code>noTTY</code> </dt>
<dd>

<p>If set, the debugger goes into <code>NonStop</code> mode and will not connect to a TTY. If interrupted (or if control goes to the debugger via explicit setting of $DB::signal or $DB::single from the Perl script), it connects to a TTY specified in the <code>TTY</code> option at startup, or to a tty found at runtime using the <code>Term::Rendezvous</code> module of your choice.</p>

<p>This module should implement a method named <code>new</code> that returns an object with two methods: <code>IN</code> and <code>OUT</code>. These should return filehandles to use for debugging input and output correspondingly. The <code>new</code> method should inspect an argument containing the value of <code>$ENV{PERLDB_NOTTY}</code> at startup, or <code>&quot;$ENV{HOME}/.perldbtty$$&quot;</code> otherwise. This file is not inspected for proper ownership, so security hazards are theoretically possible.</p>

</dd>
<dt id="ReadLine"><a class="permalink" href="perldebug.html#ReadLine">#</a><code>ReadLine</code> </dt>
<dd>

<p>If false, readline support in the debugger is disabled in order to debug applications that themselves use ReadLine.</p>

</dd>
<dt id="NonStop"><a class="permalink" href="perldebug.html#NonStop">#</a><code>NonStop</code> </dt>
<dd>

<p>If set, the debugger goes into non-interactive mode until interrupted, or programmatically by setting $DB::signal or $DB::single.</p>

</dd>
</dl>

<p>Here&#39;s an example of using the <code>$ENV{PERLDB_OPTS}</code> variable:</p>

<pre><code class="plaintext">$ PERLDB_OPTS=&quot;NonStop frame=2&quot; perl -d myprogram</code></pre>

<p>That will run the script <b>myprogram</b> without human intervention, printing out the call tree with entry and exit points. Note that <code>NonStop=1 frame=2</code> is equivalent to <code>N f=2</code>, and that originally, options could be uniquely abbreviated by the first letter (modulo the <code>Dump*</code> options). It is nevertheless recommended that you always spell them out in full for legibility and future compatibility.</p>

<p>Other examples include</p>

<pre><code class="plaintext">$ PERLDB_OPTS=&quot;NonStop LineInfo=listing frame=2&quot; perl -d myprogram</code></pre>

<p>which runs script non-interactively, printing info on each entry into a subroutine and each executed line into the file named <i>listing</i>. (If you interrupt it, you would better reset <code>LineInfo</code> to something &quot;interactive&quot;!)</p>

<p>Other examples include (using standard shell syntax to show environment variable settings):</p>

<pre><code class="plaintext">$ ( PERLDB_OPTS=&quot;NonStop frame=1 AutoTrace LineInfo=tperl.out&quot;
    perl -d myprogram )</code></pre>

<p>which may be useful for debugging a program that uses <code>Term::ReadLine</code> itself. Do not forget to detach your shell from the TTY in the window that corresponds to <i>/dev/ttyXX</i>, say, by issuing a command like</p>

<pre><code class="plaintext">$ sleep 1000000</code></pre>

<p>See <a href="perldebguts.html#Debugger-Internals">&quot;Debugger Internals&quot; in perldebguts</a> for details.</p>

<h2 id="Debugger-Input/Output"><a class="permalink" href="perldebug.html#Debugger-Input/Output">#</a><a id="Debugger1"></a><a id="Debugger-Input-Output"></a>Debugger Input/Output</h2>

<dl>

<dt id="Prompt"><a class="permalink" href="perldebug.html#Prompt">#</a>Prompt</dt>
<dd>

<p>The debugger prompt is something like</p>

<pre><code class="plaintext">DB&lt;8&gt;</code></pre>

<p>or even</p>

<pre><code class="plaintext">DB&lt;&lt;17&gt;&gt;</code></pre>

<p>where that number is the command number, and which you&#39;d use to access with the built-in <b>csh</b>-like history mechanism. For example, <code>!17</code> would repeat command number 17. The depth of the angle brackets indicates the nesting depth of the debugger. You could get more than one set of brackets, for example, if you&#39;d already at a breakpoint and then printed the result of a function call that itself has a breakpoint, or you step into an expression via <code>s/n/t expression</code> command.</p>

</dd>
<dt id="Multiline-commands"><a class="permalink" href="perldebug.html#Multiline-commands">#</a><a id="Multiline"></a>Multiline commands</dt>
<dd>

<p>If you want to enter a multi-line command, such as a subroutine definition with several statements or a format, escape the newline that would normally end the debugger command with a backslash. Here&#39;s an example:</p>

<pre><code class="plaintext">DB&lt;1&gt; for (1..4) {         \
cont:     print &quot;ok\n&quot;;   \
cont: }
ok
ok
ok
ok</code></pre>

<p>Note that this business of escaping a newline is specific to interactive commands typed into the debugger.</p>

</dd>
<dt id="Stack-backtrace"><a class="permalink" href="perldebug.html#Stack-backtrace">#</a><a id="Stack"></a>Stack backtrace  </dt>
<dd>

<p>Here&#39;s an example of what a stack backtrace via <code>T</code> command might look like:</p>

<pre><code class="plaintext">$ = main::infested called from file &#39;Ambulation.pm&#39; line 10
@ = Ambulation::legs(1, 2, 3, 4) called from file &#39;camel_flea&#39;
                                                         line 7
$ = main::pests(&#39;bactrian&#39;, 4) called from file &#39;camel_flea&#39;
                                                         line 4</code></pre>

<p>The left-hand character up there indicates the context in which the function was called, with <code>$</code> and <code>@</code> meaning scalar or list contexts respectively, and <code>.</code> meaning void context (which is actually a sort of scalar context). The display above says that you were in the function <code>main::infested</code> when you ran the stack dump, and that it was called in scalar context from line 10 of the file <i>Ambulation.pm</i>, but without any arguments at all, meaning it was called as <code>&amp;infested</code>. The next stack frame shows that the function <code>Ambulation::legs</code> was called in list context from the <i>camel_flea</i> file with four arguments. The last stack frame shows that <code>main::pests</code> was called in scalar context, also from <i>camel_flea</i>, but from line 4.</p>

<p>If you execute the <code>T</code> command from inside an active <code>use</code> statement, the backtrace will contain both a <code>require</code> frame and an <code>eval</code> frame.</p>

</dd>
<dt id="Line-Listing-Format"><a class="permalink" href="perldebug.html#Line-Listing-Format">#</a><a id="Line"></a>Line Listing Format</dt>
<dd>

<p>This shows the sorts of output the <code>l</code> command can produce:</p>

<pre><code>  DB&lt;&lt;13&gt;&gt; l
101:        @i{@i} = ();
102:b       @isa{@i,$pack} = ()
103             if(exists $i{$prevpack} || exists $isa{$pack});
104     }
105
106     next
107==&gt;      if(exists $isa{$pack});
108
109:a   if ($extra-- &gt; 0) {
110:        %isa = ($pack,1);</code></pre>

<p>Breakable lines are marked with <code>:</code>. Lines with breakpoints are marked by <code>b</code> and those with actions by <code>a</code>. The line that&#39;s about to be executed is marked by <code>==&gt;</code>.</p>

<p>Please be aware that code in debugger listings may not look the same as your original source code. Line directives and external source filters can alter the code before Perl sees it, causing code to move from its original positions or take on entirely different forms.</p>

</dd>
<dt id="Frame-listing"><a class="permalink" href="perldebug.html#Frame-listing">#</a><a id="Frame"></a>Frame listing</dt>
<dd>

<p>When the <code>frame</code> option is set, the debugger would print entered (and optionally exited) subroutines in different styles. See <a href="perldebguts.html">perldebguts</a> for incredibly long examples of these.</p>

</dd>
</dl>

<h2 id="Debugging-Compile-Time-Statements"><a class="permalink" href="perldebug.html#Debugging-Compile-Time-Statements">#</a><a id="Debugging"></a>Debugging Compile-Time Statements</h2>

<p>If you have compile-time executable statements (such as code within BEGIN, UNITCHECK and CHECK blocks or <code>use</code> statements), these will <i>not</i> be stopped by debugger, although <code>require</code>s and INIT blocks will, and compile-time statements can be traced with the <code>AutoTrace</code> option set in <code>PERLDB_OPTS</code>). From your own Perl code, however, you can transfer control back to the debugger using the following statement, which is harmless if the debugger is not running:</p>

<pre><code>$DB::single = 1;</code></pre>

<p>If you set <code>$DB::single</code> to 2, it&#39;s equivalent to having just typed the <code>n</code> command, whereas a value of 1 means the <code>s</code> command. The <code>$DB::trace</code> variable should be set to 1 to simulate having typed the <code>t</code> command.</p>

<p>Another way to debug compile-time code is to start the debugger, set a breakpoint on the <i>load</i> of some module:</p>

<pre><code class="plaintext">  DB&lt;7&gt; b load f:/perllib/lib/Carp.pm
Will stop on load of &#39;f:/perllib/lib/Carp.pm&#39;.</code></pre>

<p>and then restart the debugger using the <code>R</code> command (if possible). One can use <code>b compile subname</code> for the same purpose.</p>

<h2 id="Debugger-Customization"><a class="permalink" href="perldebug.html#Debugger-Customization">#</a><a id="Debugger2"></a>Debugger Customization</h2>

<p>The debugger probably contains enough configuration hooks that you won&#39;t ever have to modify it yourself. You may change the behaviour of the debugger from within the debugger using its <code>o</code> command, from the command line via the <code>PERLDB_OPTS</code> environment variable, and from customization files.</p>

<p>You can do some customization by setting up a <i>.perldb</i> file, which contains initialization code. For instance, you could make aliases like these (the last one is one people expect to be there):</p>

<pre><code>$DB::alias{&#39;len&#39;}  = &#39;s/^len(.*)/p length($1)/&#39;;
$DB::alias{&#39;stop&#39;} = &#39;s/^stop (at|in)/b/&#39;;
$DB::alias{&#39;ps&#39;}   = &#39;s/^ps\b/p scalar /&#39;;
$DB::alias{&#39;quit&#39;} = &#39;s/^quit(\s*)/exit/&#39;;</code></pre>

<p>You can change options from <i>.perldb</i> by using calls like this one;</p>

<pre><code>parse_options(&quot;NonStop=1 LineInfo=db.out AutoTrace=1 frame=2&quot;);</code></pre>

<p>The code is executed in the package <code>DB</code>. Note that <i>.perldb</i> is processed before processing <code>PERLDB_OPTS</code>. If <i>.perldb</i> defines the subroutine <code>afterinit</code>, that function is called after debugger initialization ends. <i>.perldb</i> may be contained in the current directory, or in the home directory. Because this file is sourced in by Perl and may contain arbitrary commands, for security reasons, it must be owned by the superuser or the current user, and writable by no one but its owner.</p>

<p>You can mock TTY input to debugger by adding arbitrary commands to @DB::typeahead. For example, your <i>.perldb</i> file might contain:</p>

<pre><code>sub afterinit { push @DB::typeahead, &quot;b 4&quot;, &quot;b 6&quot;; }</code></pre>

<p>Which would attempt to set breakpoints on lines 4 and 6 immediately after debugger initialization. Note that @DB::typeahead is not a supported interface and is subject to change in future releases.</p>

<p>If you want to modify the debugger, copy <i>perl5db.pl</i> from the Perl library to another name and hack it to your heart&#39;s content. You&#39;ll then want to set your <code>PERL5DB</code> environment variable to say something like this:</p>

<pre><code class="plaintext">BEGIN { require &quot;myperl5db.pl&quot; }</code></pre>

<p>As a last resort, you could also use <code>PERL5DB</code> to customize the debugger by directly setting internal variables or calling debugger functions.</p>

<p>Note that any variables and functions that are not documented in this document (or in <a href="perldebguts.html">perldebguts</a>) are considered for internal use only, and as such are subject to change without notice.</p>

<h2 id="Readline-Support-/-History-in-the-Debugger"><a class="permalink" href="perldebug.html#Readline-Support-/-History-in-the-Debugger">#</a><a id="Readline"></a><a id="Readline-Support-History-in-the-Debugger"></a>Readline Support / History in the Debugger</h2>

<p>As shipped, the only command-line history supplied is a simplistic one that checks for leading exclamation points. However, if you install the Term::ReadKey and Term::ReadLine modules from CPAN (such as Term::ReadLine::Gnu, Term::ReadLine::Perl, ...) you will have full editing capabilities much like those GNU <i>readline</i>(3) provides. Look for these in the <i>modules/by-module/Term</i> directory on CPAN. These do not support normal <b>vi</b> command-line editing, however.</p>

<p>A rudimentary command-line completion is also available, including lexical variables in the current scope if the <code>PadWalker</code> module is installed.</p>

<p>Without Readline support you may see the symbols &quot;^[[A&quot;, &quot;^[[C&quot;, &quot;^[[B&quot;, &quot;^[[D&quot;&quot;, &quot;^H&quot;, ... when using the arrow keys and/or the backspace key.</p>

<h2 id="Editor-Support-for-Debugging"><a class="permalink" href="perldebug.html#Editor-Support-for-Debugging">#</a><a id="Editor"></a>Editor Support for Debugging</h2>

<p>If you have the GNU&#39;s version of <b>emacs</b> installed on your system, it can interact with the Perl debugger to provide an integrated software development environment reminiscent of its interactions with C debuggers.</p>

<p>Recent versions of Emacs come with a start file for making <b>emacs</b> act like a syntax-directed editor that understands (some of) Perl&#39;s syntax. See <a href="perlfaq3.html">perlfaq3</a>.</p>

<p>Users of <b>vi</b> should also look into <b>vim</b> and <b>gvim</b>, the mousey and windy version, for coloring of Perl keywords.</p>

<p>Note that only perl can truly parse Perl, so all such CASE tools fall somewhat short of the mark, especially if you don&#39;t program your Perl as a C programmer might.</p>

<h2 id="The-Perl-Profiler"><a class="permalink" href="perldebug.html#The-Perl-Profiler">#</a><a id="The1"></a>The Perl Profiler   </h2>

<p>If you wish to supply an alternative debugger for Perl to run, invoke your script with a colon and a package argument given to the <b>-d</b> flag. Perl&#39;s alternative debuggers include a Perl profiler, <a href="./Devel::NYTProf.html">Devel::NYTProf</a>, which is available separately as a CPAN distribution. To profile your Perl program in the file <i>mycode.pl</i>, just type:</p>

<pre><code class="plaintext">$ perl -d:NYTProf mycode.pl</code></pre>

<p>When the script terminates the profiler will create a database of the profile information that you can turn into reports using the profiler&#39;s tools. See &lt;perlperf&gt; for details.</p>

<h1 id="Debugging-Regular-Expressions"><a class="permalink" href="perldebug.html#Debugging-Regular-Expressions">#</a><a id="Debugging1"></a>Debugging Regular Expressions   </h1>

<p><code>use re &#39;debug&#39;</code> enables you to see the gory details of how the Perl regular expression engine works. In order to understand this typically voluminous output, one must not only have some idea about how regular expression matching works in general, but also know how Perl&#39;s regular expressions are internally compiled into an automaton. These matters are explored in some detail in <a href="perldebguts.html#Debugging-Regular-Expressions">&quot;Debugging Regular Expressions&quot; in perldebguts</a>.</p>

<h1 id="Debugging-Memory-Usage"><a class="permalink" href="perldebug.html#Debugging-Memory-Usage">#</a><a id="Debugging2"></a>Debugging Memory Usage </h1>

<p>Perl contains internal support for reporting its own memory usage, but this is a fairly advanced concept that requires some understanding of how memory allocation works. See <a href="perldebguts.html#Debugging-Perl-Memory-Usage">&quot;Debugging Perl Memory Usage&quot; in perldebguts</a> for the details.</p>

<h1 id="SEE-ALSO"><a class="permalink" href="perldebug.html#SEE-ALSO">#</a><a id="SEE"></a>SEE ALSO</h1>

<p>You do have <code>use strict</code> and <code>use warnings</code> enabled, don&#39;t you?</p>

<p><a href="perldebtut.html">perldebtut</a>, <a href="perldebguts.html">perldebguts</a>, <a href="perl5db.pl">perl5db.pl</a>, <a href="re.html">re</a>, <a href="DB.html">DB</a>, <a href="./Devel::NYTProf.html">Devel::NYTProf</a>, <a href="Dumpvalue.html">Dumpvalue</a>, and <a href="perlrun.html">perlrun</a>.</p>

<p>When debugging a script that uses #! and is thus normally found in $PATH, the -S option causes perl to search $PATH for it, so you don&#39;t have to type the path or <code>which $scriptname</code>.</p>

<pre><code class="plaintext">$ perl -Sd foo.pl</code></pre>

<h1 id="BUGS"><a class="permalink" href="perldebug.html#BUGS">#</a>BUGS</h1>

<p>You cannot get stack frame information or in any fashion debug functions that were not compiled by Perl, such as those from C or C++ extensions.</p>

<p>If you alter your @_ arguments in a subroutine (such as with <code>shift</code> or <code>pop</code>), the stack backtrace will not show the original values.</p>

<p>The debugger does not currently work in conjunction with the <b>-W</b> command-line switch, because it itself is not free of warnings.</p>

<p>If you&#39;re in a slow syscall (like <code>wait</code>ing, <code>accept</code>ing, or <code>read</code>ing from your keyboard or a socket) and haven&#39;t set up your own <code>$SIG{INT}</code> handler, then you won&#39;t be able to CTRL-C your way back to the debugger, because the debugger&#39;s own <code>$SIG{INT}</code> handler doesn&#39;t understand that it needs to raise an exception to longjmp(3) out of slow syscalls.</p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
